home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / qbnws104.zip / DOSWATCH.ZIP / DOSWATCH.BAS next >
BASIC Source File  |  1990-07-23  |  4KB  |  121 lines

  1. '********* DOSWATCH.BAS
  2.  
  3. 'Copyright (c) 1989 Ethan Winer
  4.  
  5. 'DOSWatch is a TSR program that displays information about the current DOS
  6. 'service number at the top of the screen everytime an INT 21H is executed.
  7. 'To minimize the amount of memory taken when this program is resident, you
  8. 'should link with the STR00512, _NOVAL, and _NOREAD object files as follows:
  9. '
  10. '       LINK /NOE /NOD DOSWATCH STR00512 _NOVAL _NOREAD, , NUL, PDQ
  11. '
  12. 'THIS PROGRAM WILL NOT WORK WITHIN THE QUICKBASIC ENVIRONMENT.
  13.  
  14.  
  15. DEFINT A-Z
  16. '$INCLUDE: 'PDQDECL.BAS'
  17.  
  18. DIM Registers AS RegType        'RegType is defined in PDQDECL.BAS
  19.  
  20. ID$ = "DOSWatch Ver. 1.02"      'ID$ prevents multiple installs
  21.  
  22. Row = CSRLIN                    'print at the current cursor location
  23. Column = POS(0)
  24. PDQPrint ID$, Row, Column, 7    'print the installation message
  25.  
  26. DIM Message AS STRING * 66
  27. DIM DOSName AS STRING * 50
  28.  
  29. Zero$ = CHR$(0)                 'this is faster than CHR$(0) repeatedly
  30. Fifty = 50                      'this is faster to pass to BlockCopy
  31. Row = 1                         'where to print the message details
  32. Colr = 9                        'use bright blue on black for the message
  33.                                 '  (9 is bright underlined on mono systems)
  34.  
  35. Registers.IntNum = &H21         'Registers is a TYPE defined in PDQDECL.BAS
  36.                                 'specify trapping Int 21h
  37. PointIntHere Registers          'load Registers with what it needs, and pass
  38. GOTO EndIt                      '  control to the next line at each Int. 21h
  39.  
  40.  
  41. '----- the code below receives control with each Interrupt 21h
  42.  
  43. IntEntry1                       'this is the first mandatory step
  44. IntEntry2 Registers, 0          'and this is the second one
  45.  
  46. Ticks = 0                       'assume we won't pause to read the display
  47. Service = Registers.AX \ 256    'get the current service number in AH
  48.  
  49. SELECT CASE Service             'print some useful information
  50.    CASE &HE
  51.       Message$ = "Set disk drive to " + CHR$(Registers.DX + 65)
  52.  
  53.    CASE &H2C
  54.       Message$ = "Get the DOS time"
  55.  
  56.    CASE &H30
  57.       Message$ = "Get DOS version"
  58.  
  59.    CASE &H36
  60.       Message$ = "Get disk free space"
  61.  
  62.    CASE &H3B
  63.       GOSUB GetDOSName                              'load DOSName$ from DS:DX
  64.       Message$ = "Change directory to " + DOSName$
  65.  
  66.    CASE &H3C
  67.       GOSUB GetDOSName
  68.       Message$ = "Create file " + DOSName$
  69.  
  70.    CASE &H3D
  71.       GOSUB GetDOSName
  72.       Message$ = "Open file " + DOSName$
  73.  
  74.    CASE &H3E
  75.       Message$ = "Close handle " + STR$(Registers.BX)
  76.  
  77.    CASE &H3F
  78.       Message$ = "Read from handle " + STR$(Registers.BX)
  79.  
  80.    CASE &H40
  81.       Message$ = "Write to handle " + STR$(Registers.BX)
  82.  
  83.    CASE &H41
  84.       GOSUB GetDOSName
  85.       Message$ = "Delete file " + DOSName$
  86.   
  87.    CASE &H47
  88.       Message$ = "Get current directory"
  89.   
  90.    CASE &H4B
  91.       GOSUB GetDOSName
  92.       Message$ = "Exec program " + DOSName$
  93.   
  94.    CASE &H4E
  95.       GOSUB GetDOSName
  96.       Message$ = "Find first file that matches " + DOSName$
  97.  
  98.    CASE &H4F
  99.       Message$ = "Find next matching file"
  100.   
  101.    CASE ELSE
  102.       Message$ = ""
  103.  
  104. END SELECT
  105.  
  106. PDQPrint "Service: " + HEX$(Service) + " " + Message$, Row, Row, Colr
  107. IF Ticks THEN Pause Ticks
  108.  
  109. GotoOldInt Registers            'continue on to the original Int 21h
  110.  
  111. GetDOSName:                     'load DOSName$ with name pointed to by DS:DX
  112.    BlockCopy Registers.DS, Registers.DX, VARSEG(DOSName$), VARPTR(DOSName$), Fifty
  113.    Zero = INSTR(DOSName$, Zero$)           'find terminating zero byte
  114.    DOSName$ = LEFT$(DOSName$, Zero - 1)    'blank out what remains
  115.    Ticks = 8                               'pause 1/2 second for readability
  116.    RETURN
  117.  
  118. EndIt:
  119.    EndTSR ID$                              'terminate and stay resident
  120.  
  121.